﻿CREATE PROCEDURE [dbo].[SystemUser_Insert]

@CreatedBy uniqueidentifier
, @ModifiedBy uniqueidentifier
, @EmployeeID uniqueidentifier
, @UserName varchar (24)
, @Salt varchar (5000)
, @Password varchar (5000)
, @LastLoginDate datetime
, @LastPasswordChangeDate datetime
, @NextPasswordChangeDate datetime
, @ApprovedBy uniqueidentifier
, @ApprovedDate datetime
, @IsApproved bit
, @IsLoggedOn bit
, @IsLockedOut bit
AS
BEGIN
SET NOCOUNT ON

DECLARE @CreatedDate datetime
DECLARE @ModifiedDate datetime
DECLARE @Deleted bit
DECLARE @SystemUserID uniqueidentifier
SET @CreatedDate = GETDATE()
SET @ModifiedDate = GETDATE()
SET @Deleted = 0
SET @SystemUserID = NEWID()

INSERT INTO [dbo].[SystemUser] ([SystemUserID]
, [CreatedDate]
, [CreatedBy]
, [ModifiedDate]
, [ModifiedBy]
, [Deleted]
, [EmployeeID]
, [UserName]
, [Salt]
, [Password]
, [LastLoginDate]
, [LastPasswordChangeDate]
, [NextPasswordChangeDate]
, [ApprovedBy]
, [ApprovedDate]
, [IsApproved]
, [IsLoggedOn]
, [IsLockedOut]
)
VALUES (@SystemUserID
, @CreatedDate
, @CreatedBy
, @ModifiedDate
, @ModifiedBy
, @Deleted
, @EmployeeID
, @UserName
, @Salt
, @Password
, @LastLoginDate
, @LastPasswordChangeDate
, @NextPasswordChangeDate
, @ApprovedBy
, @ApprovedDate
, @IsApproved
, @IsLoggedOn
, @IsLockedOut
)

SELECT @SystemUserID [SystemUserID]
END
